$.ajaxSetup({
    complete: function (xhr) {
        const resp = xhr.responseJSON;
        if (resp.code === 403) {
            layui.use("layer", function () {
                layui.layer.msg("你没有登录，请登录！", {
                    icon: 2,
                    time: 1000,
                    end: function () {
                        window.parent.location.href = '../login.html';
                    }
                })
            })
        }
    }
})

 // 传入时间对象转为自己想要的格式显示
 function dateFormat(date = new Date(), format = "y-m-d h:i:s") {
    if (typeof date == "string") {
        date = new Date(date);
    }
    const y = date.getFullYear(),
        m = _.padStart(date.getMonth() + 1, 2, "0"),
        d = _.padStart(date.getDate(), 2, "0"),
        h = _.padStart(date.getHours(), 2, "0"),
        i = _.padStart(date.getMinutes(), 2, "0"),
        s = _.padStart(date.getSeconds(), 2, "0")
    return format.replace("y", y).replace("m", m).replace("d", d).replace("h", h).replace("i", i).replace("s",
        s);
}
